import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true) {
			String str = br.readLine();
			if(str.trim().equals("0 0")) {
				break;
			}
			StringTokenizer sToken = new StringTokenizer(str, " ");
			int n = Integer.parseInt(sToken.nextToken());
			int m = Integer.parseInt(sToken.nextToken());
			
			int r1 = 0, r2 = 0, r3 = 0;
			for(int i = 0; i < n; i++) {
				str = br.readLine();
				sToken = new StringTokenizer(str, " ");
				int c1 = 0 , c2 = 0, c3 = 0;
				for(int j = 0; j < m; j++) {
					c3 = Math.max(c2, c1 + Integer.parseInt(sToken.nextToken()));
					
					c1 = c2;
					c2 = c3;
				}
				r3 = Math.max(r2, r1 + c3);
				r1 = r2;
				r2 = r3;
			}
			System.out.println(r3);
		}
	}

}
